Make the datasets cache work in Python 3
authorDebian Science Maintainers <debian-science-maintainers@lists.alioth.debian.org>
Sat, 2 Mar 2019 14:59:35 +0000 (14:59 +0000)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sat, 2 Mar 2019 14:59:35 +0000 (14:59 +0000)
Fixes URLError messages appearing in the built documentation

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: not-needed (upstream fixed this in _cache_it instead)

Gbp-Pq: Name python3_dataset_caching.patch

statsmodels/datasets/utils.py

index b5a223d73d68280e073fb88dbfbe82fb654039cc..0d875956f0a98d8a3508d4063ac80f94a839a79f 100644 (file)
@@ -183,8 +183,8 @@ def _open_cache(cache_path):
         # Python 3 build
         import zlib
         data = zlib.decompress(open(cache_path, 'rb').read())
-        # return as bytes object encoded in utf-8 for cross-compat of cached
-        data = cPickle.loads(data).encode('utf-8')
+        # treat Python 2 strings as bytes for cross-compat of cached
+        data = cPickle.loads(data, encoding='bytes')
     else:
         data = open(cache_path, 'rb').read().decode('zip')
         data = cPickle.loads(data)